fix(agents): point misplaced generation kwargs at generate_content_config - #6837
fix(agents): point misplaced generation kwargs at generate_content_config#6837a2105z wants to merge 2 commits into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
8fe8946 to
9c94f11
Compare
|
@googlebot I fixed it. |
|
Hi @a2105z — thanks for picking this up so quickly, and for reading the actual failure mode rather than just papering over it. Two parts of this I want to keep regardless of where we land: deriving the field names from GenerateContentConfig.model_fields instead of hardcoding them, and redirecting system_instruction / response_schema to the LlmAgent arguments that own them with a message that says so. That second one is a genuinely nice touch and I hadn't seen it proposed anywhere. That said, after going through #6836 I think we should take the reporter's option 2 — a clear error message — rather than option 1, and I'd rather tell you now than after another review round. The reason is in the issue title: "no discoverable path to generate_content_config". What cost @CarSanoja a debugging session wasn't that temperature= is rejected, it's that the rejection points nowhere. An error that names the destination fixes that for every field at once: Accepting the kwargs solves it too, but it commits us to more than it looks like. It gives two spellings for the same setting, and every field google-genai adds becomes a decision about whether to promote it — a decision we can't easily revise later, because once these are accepted they're public API. There's also a coverage asymmetry that's easy to miss. GenerateContentConfig has 35 fields today. Folding a subset means the ones left out still fail with the same opaque extra_forbidden, and arguably worse than before, because the user has now learned that generation settings work as kwargs. An error-message fix derived from model_fields covers all 35 and anything added later, with nothing to maintain. If you're up for reworking it, what we'd take is roughly:
Thanks again |
|
Following up on Dean's redirect, since I filed this one and had already signed off on the kwargs version. To be clear about what my earlier test did and did not say: #6837 does fix the failure and I stand by those five results. Dean's objection is about API surface rather than correctness, and on that axis I think he is right — it is also the option I put in the issue. The title is "no discoverable path", and what cost me the session was not that I built Dean's spec against adk-python 2.7.0 to check it survives contact — a
Two things from @a2105z's PR that should survive into the smaller shape:
One trap for whoever writes it: @a2105z happy to hand you the implementation and the edge-case tests so this stays your PR, or to open it myself if you would rather not redo it — whichever unblocks it faster. Either way I will re-test whatever lands before merge. |
|
@DeanChensj @CarSanoja Thanks — reworked this to option 2 instead of folding the kwargs. Pushed on this branch. The validator is now a
Class docstring now shows the @CarSanoja kept this as my PR — your edge-case table is covered in |
|
Re-tested, as promised. This resolves the issue for me, and it is better than what I proposed. Clean venv, Python 3.13, google-genai 2.20.0, branch at 14ac8d2. Your own suite:
Two things you did that I had not thought of, and that I would keep:
One optional bit of polish, not a blocker, and I would understand leaving it: when a real typo and a config field arrive together ( Thanks for reworking it and for the tests — |
Users coming from google-genai pass temperature= (and similar knobs) on LlmAgent, which failed with extra_forbidden and no pointer to generate_content_config. Fold GenerateContentConfig fields into that config, and point reserved fields at the LlmAgent argument that owns them. Fixes google#6836
…nfig Keep LlmAgent construction from accepting temperature= and other GenerateContentConfig fields as public API. Raise a ValueError that names generate_content_config instead, with reserved-field redirects and camelCase aliases preserved. Report redirects, config fields, and extras in one error when they arrive together.
14ac8d2 to
07349c5
Compare
|
Follow-up on the optional polish: pydantic's
A typo alone is still left to pydantic |
07349c5 to
33277b5
Compare
Summary
LlmAgent(temperature=0.1)(and otherGenerateContentConfigknobs) now raises aValueErrorthat namesgenerate_content_config=types.GenerateContentConfig(...)instead of failing with opaqueextra_forbidden.Reserved knobs that already have an agent field (
system_instruction,response_schema) still redirect toinstruction=/output_schema=. Unknown keys that are not config fields are left alone so a real typo staysextra_forbidden. CamelCase aliases (topP,maxOutputTokens) are included.toolsis skipped because it is already anLlmAgentfield.This is option 2 from #6836, per review on this PR: do not promote generation settings as public kwargs.
Closes: #6836
Test plan
Unit Tests:
Covers the original
temperature=failure, multiple knobs named in one error, camelCase aliases, reserved-field redirects, typos remainingextra_forbidden,tools=not hijacked, and subclasses inheriting the validator.Manual End-to-End (E2E) Tests:
Checklist